//
//  LinkedList_traverse.swift
//  SwiftyDSA
//
//  Created by Archer on 2018/8/8.
//  Copyright © 2018年 Archer. All rights reserved.
//

import Foundation

extension LinkedList {
    public func forEach(_ body: (Element) throws -> Void ) rethrows {
        var nd = _header.successor
        while let node = nd, nd !== _trailer {
            try body(node.value!)
            nd = node.successor
        }
    }
}
